package no.sachmuld.methodcombination.api.reflection;

import no.sachmuld.methodcombination.api.reflection.component.MethodCombination;
import no.sachmuld.methodcombination.impl.validate.MethodCombinationValidationError;

import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 *
 */
public class MethodCombinationValidator extends no.sachmuld.methodcombination.api.MethodCombinationValidator {

    private Class behaviourClass;
    private Class targetClass;
    private Map<Method, MethodCombination> methodCombinationMap;

    public MethodCombinationValidator(Class behaviourClass, Class targetClass, Map<Method, MethodCombination> methodCombinationMap) {
        this.behaviourClass = behaviourClass;
        this.targetClass = targetClass;
        this.methodCombinationMap = methodCombinationMap;
    }

    @Override
    protected Class findTargetClass(List<MethodCombinationValidationError> errors) {
        return targetClass;
    }

    @Override
    protected Class findBehaviourClass(List<MethodCombinationValidationError> errors) {
        return behaviourClass;
    }

    @Override
    protected Set<Method> findTargetMethods(List<MethodCombinationValidationError> errors) {
        return methodCombinationMap.keySet();
    }

    @Override
    protected MethodCombination findMethodCombination(Method method, List<MethodCombinationValidationError> errors) {
        return methodCombinationMap.get(method);
    }
}
